import Vue from 'vue'
import VueRouter from "vue-router";
Vue.use(VueRouter)

// 导入组件
import layout from '@/views/layout'
import detail from '@/views/article-detail'
import article from '@/views/article'
import collect from '@/views/collect'
import like from '@/views/like'
import user from '@/views/user'



const router = new VueRouter({
  routes: [
    // 如果路径只是写一个 `/` 就是为了一打开页面就默认显示layout这个路由
    { 
      name: 'layout', 
      path: '/', 
      component: layout,
      children: [
        { name: 'article', path: 'article', component: article },
        { name: 'collect', path: 'collect', component: collect },
        { name: 'like', path: 'like', component: like },
        // 动态路由匹配
        { name: 'user', path: 'user/:id', component: user },
      ]
    },
    { name: 'detail', path: '/detail/:id', component: detail },
  ]
})

export default router